package com.jt.controller;

import com.jt.pojo.User;
import com.jt.pojo.User2;
import org.springframework.http.HttpRequest;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@RestController
@RequestMapping("/user")
public class UserController3 {
    public void findUser(HttpServletRequest request, HttpServletResponse response) throws IOException {
        String id = request.getParameter("id");
        int i = Integer.parseInt(id);
        String name = request.getParameter("name");
        response.getWriter().write(i+":"+name);
    }
    @RequestMapping("/findUser2")
    public  String findUser2(Integer id,String name){
        return id + ":" + name;
    }
    @RequestMapping("/getUser")
    public User2 getUser(User2 user){
        return user;
    }
    @RequestMapping("/result/{id}/{name}")
    public User2 restFul(@PathVariable Integer id,@PathVariable String name){
        User2 user2 = new User2();
        user2.setId(id);
        user2.setName(name);
        return user2;
    }
    @GetMapping("/restFul2/{id}/{name}/{age}")
    public User2 restFul2(User2 user2){
        return user2;
    }
    public String[] saveHobby(String[] hobby){
        return hobby;
    }
}
